#include "pcb.h"

PCB::PCB()
{

}

PCB::PCB(QString processName,QString PID,QString inPut,QString outPut,int needTime,int priorityWeight,int mode,int needMemorySize)
{
    this->processName = processName;
    this->PID = PID;
    this->inPut = inPut;
    this->outPut = outPut;
    this->needTime = needTime;
    this->priorityWeight = priorityWeight;
    this->mode = mode;
    this->needMemorySize = needMemorySize;
    //this->PCBPointer = PCBPointer;
}

PCB::PCB(QString processName,QString PID,QString inPut,QString outPut,int needTime,int priorityWeight,int mode,int needMemorySize,QString frontID)
{
    this->processName = processName;
    this->PID = PID;
    this->inPut = inPut;
    this->outPut = outPut;
    this->needTime = needTime;
    this->priorityWeight = priorityWeight;
    this->mode = mode;
    this->needMemorySize = needMemorySize;
    this->frontID = frontID;
    //this->PCBPointer = PCBPointer;
}

PCB::PCB(QString processName,QString PID,QString inPut,QString outPut,int needTime,int priorityWeight,int mode,int needMemorySize,QString frontID,QString backID)
{
    this->processName = processName;
    this->PID = PID;
    this->inPut = inPut;
    this->outPut = outPut;
    this->needTime = needTime;
    this->priorityWeight = priorityWeight;
    this->mode = mode;
    this->needMemorySize = needMemorySize;
    this->frontID = frontID;
    this->backID = backID;
    //this->PCBPointer = PCBPointer;
}

//PCB::PCB(PCB &p)
//{
//    this->processName = p.processName;
//    this->PID = p.PID;
//    this->inPut = p.inPut;
//    this->outPut = p.outPut;
//    this->needTime = p.needTime;
//    this->priorityWeight = p.priorityWeight;
//    this->mode = p.mode;
//}

void PCB::copyPCB(PCB &p1, PCB &p2)
{
    p1.PID = p2.PID;
    p1.mode = p2.mode;
    p1.inPut = p2.inPut;
    p1.outPut = p2.outPut;
    p1.needTime = p2.needTime;
    p1.olderTime = p2.olderTime;
    p1.processName = p2.processName;
    p1.priorityWeight = p2.priorityWeight;
    p1.needMemorySize = p2.needMemorySize;
    p1.memoryStartAddress = p2.memoryStartAddress;
    p1.frontID = p2.frontID;
    p1.backID = p2.backID;
}

void PCB::randomPCB(PCB &p1)
{
    p1.PID =QString::number(1000+rand()%9000);
    p1.mode = 1;
    p1.inPut = "";
    p1.outPut = "";
    p1.needTime = rand()%10+1;
    p1.olderTime = 0;
    p1.processName = "Pro" + QString::number(rand()%100);
    p1.priorityWeight = rand()%15+1;
    p1.needMemorySize = rand()%30+10;

}
